﻿using System.Collections.Generic;
using Orchard.ContentManagement;
using Piedone.ContentTemplates.Models;

namespace Piedone.ContentTemplates.Services
{
    public class TemplateService : ITemplateService
    {
        private readonly IEnumerable<ITemplateLoader> _templateLoaders;
        private readonly IContentManager _contentManager;


        public TemplateService(IEnumerable<ITemplateLoader> templateLoaders, IContentManager contentManager)
        {
            _templateLoaders = templateLoaders;
            _contentManager = contentManager;
        }


        public IEnumerable<ITemplateLoader> GetLoaders()
        {
            return _templateLoaders;
        }

        public IContentQuery GetTemplatesQuery()
        {
            return _contentManager.Query().Where<TemplatePartRecord>(record => record.IsTemplate);
        }
    }
}